{% assign blockId = block_id | default: section.block_id %}
{% assign data = section.settings %}

<div class="block_testimonials" style="--bg: {{data.bg_color}};">
  <div class="container_wrapper">
    {% include 'swiper_title',title: data.title,detail: data.detail,blockId: blockId %}
    <div class="swiper overflow-hidden" id="swiper-{{blockId}}">
      <ul class="swiper-wrapper" style="--text-bg: {{data.text_bg}};--radius: {{data.radius}}px;--text-color: {{data.text_color}};--star-color: {{data.star_color}};">
        {% for block in section.blocks %}
          <li class="swiper-slide">
            <div class="text_box">
              {% if block.title != '' %}
                <div class="item_title public_title">{{block.title}}</div>
              {% endif %}
              {% if block.detail != '' %}
                <div class="item_detail mt-4">{{block.detail}}</div>
              {% endif %}
              <div class="star_box mt-4">
                {% for i in (1..5) %}
                  <span class="star_span {% if forloop.index <= block.star %}bright{% endif %}">
                    {% include 'svg',svg: 'star_icon' %}
                  </span>
                {% endfor %}
              </div>
            </div>
            <div class="author_box mt-5 flex gap-5">

              <div class="author_img">
                {% include 'lazy_img',src: block.image.src,alt: block.image.alt %}
              </div>
              <div class="author_text">
                <div class="author_name">{{block.author}}</div>
                <div class="author_sub">{{block.author_sub}}</div>
              </div>
            </div>
          </li>
        {% endfor %}
      </ul>
    </div>
  </div>
</div>


<script>
  (function() {
    let blocksSize = '{{section.blocks.size}}';
    let options = {}

    if ((blocksSize > Number(`{{data.pc_number}}`) && $(window).width() >= 768) || (blocksSize > Number(`{{data.yd_number}}`) && $(window).width() < 768)) {
      options.navigation = {
        nextEl: `#swiper-button-next-{{blockId}}`,
        prevEl: `#swiper-button-prev-{{blockId}}`
      }
      $(`#swiper_title_wrapper-{{blockId}} .right`).css('display', 'flex')
    }

    let swiper = new Swiper(`#swiper-{{blockId}}`, {
      slidesPerView: $(window).width() >= 768
        ? '{{data.pc_number}}'
        : '{{data.yd_number}}',
      spaceBetween: 20,
      autoHeight: true,
      ... options
    })
  })()
</script>
{% schema %}
  {
    "tag": "",
    "class": "block_slides",
    "is_global": false,
    "icon": "icon-lunbotu",
    "name": {
      "zh_CN": "团队介绍",
      "en_US": "Team Introduction"
    },
    "max_blocks": "10",
    "settings": [
      {
        "type": "card_header",
        "label": {
          "zh_CN": "设置",
          "en_US": "Settings"
        }
      },
      {
        "type": "card_input",
        "id": "title",
        "label": {
          "zh_CN": "标题",
          "en_US": "Title"
        },
        "placeholder": {
          "zh_CN": "请输入标题",
          "en_US": "Please enter title"
        },
        "default": "Collection List"
      },
      {
        "type": "card_text_editor",
        "id": "detail",
        "label": {
          "zh_CN": "简短描述",
          "en_US": "Short description"
        },
        "placeholder": {
          "zh_CN": "请输入描述",
          "en_US": "Please enter a description"
        },
        "default": "Collection Detail"
      },
      {
        "type": "card_slider",
        "id": "pc_number",
        "max": "6",
        "min": "3",
        "label": {
          "zh_CN": "PC每排数量",
          "en_US": "PC number per row"
        },
        "default": "3"
      }, {
        "type": "card_slider",
        "id": "yd_number",
        "max": "2",
        "min": "1",
        "label": {
          "zh_CN": "移动端每排数量",
          "en_US": "Number of mobile terminals per row"
        },
        "default": "2"
      }, {
        "type": "card_slider",
        "label": {
          "zh_CN": "圆角"
        },
        "id": "radius",
        "max": 50,
        "min": 0,
        "unit": "px",
        "default": 30
      }, {
        "type": "card_header",
        "label": {
          "zh_CN": "颜色设置",
          "en_US": "Color Settings"
        }
      }, {
        "type": "card_color",
        "id": "bg_color",
        "label": {
          "zh_CN": "背景颜色",
          "en_US": "Background color"
        },
        "default": "#fdf9ee"
      }, {
        "type": "card_color",
        "id": "text_bg",
        "label": {
          "zh_CN": "文字背景"
        },
        "default": "#fff"
      }, {
        "type": "card_color",
        "id": "text_color",
        "label": {
          "zh_CN": "文字颜色",
          "en_US": "Text color"
        },
        "default": "#333333"
      }, {
        "type": "card_color",
        "id": "star_color",
        "label": {
          "zh_CN": "评分颜色"
        },
        "default": "#ffce31"
      }
    ],
    "blocks": [
      {
        "name": {
          "zh_CN": "团队介绍",
          "en_US": "Team Introduction"
        },
        "type": "item",
        "settings": [
          {
            "type": "card_input",
            "label": {
              "zh_CN": "标题",
              "en_US": "Title"
            },
            "id": "title",
            "default": "Testimonial"
          },
          {
            "type": "card_text_editor",
            "label": {
              "zh_CN": "简短描述",
              "en_US": "Short description"
            },
            "id": "detail",
            "default": "Thanks for the feedback. We are always looking to improve our product and we would love to look into this issue with you further."
          },
          {
            "type": "card_slider",
            "label": {
              "zh_CN": "评分"
            },
            "id": "star",
            "max": 5,
            "min": 0,
            "unit": "",
            "default": 5
          },
          {
            "type": "card_image",
            "label": {
              "zh_CN": "成员头像"
            },
            "default": {
              "src": "",
              "alt": ""
            },
            "info": {
              "zh_CN": "尺寸建议：宽高400*400px",
              "en_US": "Size suggestion: Width and height 400*400px"
            },
            "id": "image"
          }, {
            "type": "card_input",
            "label": {
              "zh_CN": "成员名称"
            },
            "id": "author",
            "default": "Author"
          }, {
            "type": "card_text_editor",
            "label": {
              "zh_CN": "成员描述"
            },
            "id": "author_sub",
            "default": "Sub title"
          }
        ]
      }
    ],
    "default": {
      "settings": {
        "title": "Shop by collection",
        "detail": "Share information about your brand with your customers.",
        "pc_number": "3",
        "yd_number": "1",
        "radius": 30,
        "bg_color": "#fdf9ee",
        "text_bg": "#fff",
        "text_color": "#333333",
        "star_color": "#ffce31"
      },
      "blocks": [
        {
          "title": "Testimonial",
          "detail": "Thanks for the feedback. We are always looking to improve our product and we would love to look into this issue with you further.",
          "star": 5,
          "image": {
            "src": "",
            "alt": ""
          },
          "author": "Author",
          "author_sub": "Sub title",
          "block_type": "item"
        }, {
          "title": "Testimonial",
          "detail": "Thanks for the feedback. We are always looking to improve our product and we would love to look into this issue with you further.",
          "star": 5,
          "image": {
            "src": "",
            "alt": ""
          },
          "author": "Author",
          "author_sub": "Sub title",
          "block_type": "item"
        }, {
          "title": "Testimonial",
          "detail": "Thanks for the feedback. We are always looking to improve our product and we would love to look into this issue with you further.",
          "star": 5,
          "image": {
            "src": "",
            "alt": ""
          },
          "author": "Author",
          "author_sub": "Sub title",
          "block_type": "item"
        }, {
          "title": "Testimonial",
          "detail": "Thanks for the feedback. We are always looking to improve our product and we would love to look into this issue with you further.",
          "star": 5,
          "image": {
            "src": "",
            "alt": ""
          },
          "author": "Author",
          "author_sub": "Sub title",
          "block_type": "item"
        }
      ]
    }
  }
{% endschema %}